package february.test_2_1;

public class TestMain1 {
    public int n = 1;
    public int getLCA(int a, int b) {
        // write code here
        return A(n,a,b);
    }
    public int A(int n,int a,int b) {
        if(n == a || n == b ) {
            return n;
        }
        if(n > a || n > b) {
            return -1;
        }
        int x =A(2*n,a,b);
        int y = A(2*n + 1,a,b);
        if(x != -1 && y != -1) {
            return n;
        } else if (x != -1) {
            return x;
        } else if(y != -1) {
            return y;
        }
        return -1;
    }

    public static void main(String[] args) {
        TestMain1 testMain1 = new TestMain1();
        System.out.println(testMain1.getLCA(4, 5));
    }

}
